package com.stm.bi.service;

import com.stm.bi.dto.query.*;
import com.stm.bi.dto.vo.*;
import com.stm.bi.model.Chart;
import com.stm.bi.model.DatatablePage;
import com.stm.bi.report.*;
import com.stm.bi.report.salesTrend.SalesTrendDetailLineChartQueryExe;
import com.stm.bi.report.salesTrend.SalesTrendLineChartQueryExe;
import com.stm.bi.report.salesTrend.SalesTrendTableQueryExe;
import com.stm.framework.dto.Response;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author liuyx
 * @date 2025/2/13 11:06
 */
@Service
public class PerformanceService {
    @Resource
    private SalesProIndexChartQueryExe salesProIndexChartQueryExe;

    @Resource
    private ShopRankingChartQueryExe shopRankingChartQueryExe;

    @Resource
    private StyleTypeQtyChartQueryExe styleTypeQtyChartQueryExe;

    @Resource
    private RegionalSaleRankChartQueryExe regionalSaleRankChartQueryExe;

    @Resource
    private RegionalCustomerRankChartQueryExe regionalCustomerRankChartQueryExe;

    @Resource
    private RegionalProportionOfCustomersChartQueryExe regionalProportionOfCustomersChartQueryExe;
    @Resource
    private RegionalProportionOfCustomersToBQueryExe regionalProportionOfCustomersToBQueryExe;

    @Resource
    private TurnoverRankChartToBQueryExe turnoverRankChartToBQueryExe;

    @Resource
    private BizCustomersRankChartToBQueryExe bizCustomersRankChartToBQueryExe;
    @Resource
    private RegionalStyleSalesQueryExe regionalStyleSalesQueryExe;
    @Resource
    private RegionalTurnoverQueryExe regionalTurnoverQueryExe;
    @Resource
    private RegionalTurnoverMapQueryExe regionalTurnoverMapQueryExe;
    @Resource
    private SalesTrendLineChartQueryExe salesTrendLineChartQueryExe;
    @Resource
    private SalesTrendDetailLineChartQueryExe salesTrendDetailLineChartQueryExe;
    @Resource
    private SalesTrendTableQueryExe salesTrendTableQueryExe;
    @Resource
    private DeptSalesTrendQueryExe deptSalesTrendQueryExe;
    @Resource
    private RegionalStyleSalesMapQueryExe regionalStyleSalesMapQueryExe;

    public Response<Chart<YesterdayVO>> shopRanking(Long deptId) {
        return shopRankingChartQueryExe.query(DeptChartQuery.builder().deptId(deptId).build());
    }


    public Response<Chart<SalesProIndexChartVO>> getSalesProIndexChart(Long deptId) {
        return salesProIndexChartQueryExe.query(DeptChartQuery.builder().deptId(deptId).build());
    }


    public Response<Chart> styleTypeQty(Long deptId) {
        return styleTypeQtyChartQueryExe.query(DeptChartQuery.builder().deptId(deptId).build());
    }

    public Response<Chart<RegionalCustomerVO>> regionalProportionOfCustomersToB(RegionalSaleQry regionalSaleQry) {
        return regionalProportionOfCustomersToBQueryExe.query(regionalSaleQry);
    }

    public Response<Chart> turnoverRankChartToB(RegionalSaleQry regionalSaleQry) {
        return turnoverRankChartToBQueryExe.query(regionalSaleQry);
    }

    public Response<Chart> bizCustomersRankChartToB(RegionalSaleQry regionalSaleQry) {
        return bizCustomersRankChartToBQueryExe.query(regionalSaleQry);
    }

    public Response<Chart> regionalSaleRank(RegionalSaleQry regionalSaleQry) {
        return regionalSaleRankChartQueryExe.query(regionalSaleQry);
    }

    public Response<Chart> regionalCustomerRank(RegionalSaleQry regionalSaleQry) {
        return regionalCustomerRankChartQueryExe.query(regionalSaleQry);
    }

    public Response<Chart> regionalProportionOfCustomers(RegionalSaleQry regionalSaleQry) {
        return regionalProportionOfCustomersChartQueryExe.query(regionalSaleQry);
    }

    public Response<RegionalStyleSalesVO> regionalStyleSales(RegionalSaleQuery regionalSaleQry) {
        return regionalStyleSalesQueryExe.query(regionalSaleQry);
    }

    public Response<Chart> regionalStyleSalesMap(RegionalSaleQuery regionalSaleQry) {
        return regionalStyleSalesMapQueryExe.query(regionalSaleQry);
    }

    public Response<RegionalCustomerToBVO> regionalTurnover(RegionalSaleQuery regionalSaleQry) {
        return regionalTurnoverQueryExe.query(regionalSaleQry);
    }

    public Response<Chart> regionalTurnoverMap(RegionalSaleQuery regionalSaleQry) {
        return regionalTurnoverMapQueryExe.query(regionalSaleQry);
    }

    public Response<Chart<List<ValueVO<BigDecimal>>>> salesTrendLineChart(SalesTrendLineChartQuery query) {
        return salesTrendLineChartQueryExe.query(query);
    }

    public Response<Chart<List<List<Object>>>> salesTrendDetailLineChart(SalesTrendDetailLineChartQuery query) {
        return salesTrendDetailLineChartQueryExe.query(query);
    }

    public Response<DatatablePage> salesTrendTable(SalesTrendTableQuery query) {
        return salesTrendTableQueryExe.query(query);
    }

    public void salesTrendTableExport(HttpServletResponse response,SalesTrendTableQuery query) throws IOException {
        salesTrendTableQueryExe.export(response, query);
    }

    public Response<Chart> lineChartByDeptId(DeptSalesTrendChartQry qry) {
        return deptSalesTrendQueryExe.query(qry);
    }


}
